﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Quocity.Entities;
using System.Data;
using System.IO;
using System.Xml.Xsl;
using System.Xml;
using System.Xml.Serialization;
using System.Text;

namespace QuocityService.Sources
{
    public class PamplonaPointsOfInterestSource:IPointOfInterestSource
    {
        
        

        public List<PointOfInterest> GetList(string q, int firstItem, int pageSize)
        {
            es.navarra.administracionelectronica.Service4A service = new es.navarra.administracionelectronica.Service4A();
            DataSet dataSet = service.getDataSet();
            
            XmlDataDocument xmlDataDocument = new XmlDataDocument(dataSet);
            MemoryStream memoryStream = new MemoryStream();
            XslCompiledTransform myXslTransform;
            myXslTransform = new XslCompiledTransform();
            myXslTransform.Load(HttpContext.Current.Server.MapPath(@"~\Xsl\Pamplona.xsl"));

            XmlTextWriter xmlWriter = new XmlTextWriter(memoryStream, Encoding.UTF8);
            myXslTransform.Transform(@"c:\temp\dataset - copia.xml", new XsltArgumentList(), xmlWriter);
            memoryStream.Seek(0, SeekOrigin.Begin);

            XmlSerializer xmlSerializer = new XmlSerializer(typeof(List<PointOfInterest>));
            return xmlSerializer.Deserialize(memoryStream) as List<PointOfInterest>;



        }
    }
}